package com.example.springmvc.pojo;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

/**
 * @Description:
 * @Author: lijiewei
 * @Date: 2020/7/13$ 22:49$
 */
@Setter
@Getter
@ToString
@NoArgsConstructor
public class ApiResult {

    private int code = 200;

    private String message = "成功";

    private Object data;

    public ApiResult(String message) {
        this.message = message;
    }

    public ApiResult(Object data) {
        this.data = data;
    }

    public ApiResult(String message, Object data) {
        this.message = message;
        this.data = data;
    }

    public ApiResult(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static ApiResult ok() {
        return new ApiResult();
    }

    public static ApiResult ok(Object data) {
        return new ApiResult(data);
    }

    public static ApiResult fial() {
        return new ApiResult();
    }

    public static ApiResult fial(String message) {
        ApiResult apiResult = new ApiResult();
        apiResult.setCode(500);
        apiResult.setMessage(message);
        return apiResult;
    }

}
